package com.fh.alipay.model.convert;


import lombok.experimental.UtilityClass;
import com.fh.alipay.po.Goods;
import com.fh.alipay.model.dto.GoodsDTO;
import com.fh.alipay.model.vo.GoodsVO;
import java.util.ArrayList;
import java.util.List;

/**
 * @author fh
 * @date 2022-05-03
 * @description 转换类
 */

@UtilityClass
public class GoodsConvert {


    public static Goods toPO(GoodsDTO dto){
        Goods result = new Goods();
            result.setId(dto.getId());
            result.setCreateTime(dto.getCreateTime());
            result.setUpdateTime(dto.getUpdateTime());
            result.setGoodsId(dto.getGoodsId());
            result.setGoodsName(dto.getGoodsName());
            result.setGoodsImgRealName(dto.getGoodsImgRealName());
            result.setGoodsImgUrl(dto.getGoodsImgUrl());
            result.setGoodsCurrentPrice(dto.getGoodsCurrentPrice());
            result.setGoodsOfficialPrice(dto.getGoodsOfficialPrice());
            result.setPayType(dto.getPayType());
            result.setGoodsDetail(dto.getGoodsDetail());
            result.setAccountTag(dto.getAccountTag());
            result.setAccountDesc(dto.getAccountDesc());
            result.setAccountHolder(dto.getAccountHolder());
            result.setDelFlag(dto.getDelFlag());
        return result;
    }

    public static GoodsVO toVO(Goods po){
        GoodsVO result = new GoodsVO();
                result.setId(po.getId());
                result.setCreateTime(po.getCreateTime());
                result.setUpdateTime(po.getUpdateTime());
                result.setGoodsId(po.getGoodsId());
                result.setGoodsName(po.getGoodsName());
                result.setGoodsImgRealName(po.getGoodsImgRealName());
                result.setGoodsImgUrl(po.getGoodsImgUrl());
                result.setGoodsCurrentPrice(po.getGoodsCurrentPrice());
                result.setGoodsOfficialPrice(po.getGoodsOfficialPrice());
                result.setPayType(po.getPayType());
                result.setGoodsDetail(po.getGoodsDetail());
                result.setAccountTag(po.getAccountTag());
                result.setAccountDesc(po.getAccountDesc());
                result.setAccountHolder(po.getAccountHolder());
                result.setDelFlag(po.getDelFlag());
            return result;
    }
    public static List<GoodsVO> toVO(List<Goods> pos){
        if(pos == null){
            return null;
        }
        List<GoodsVO> list = new ArrayList<>();
        for(Goods po:pos){
            list.add(toVO(po));
        }
        return list;
    }

    public static List<Goods> toPO(List<GoodsDTO> dtos){
        if(dtos == null) {
            return null;
        }
        List<Goods> list = new ArrayList<>();
        for(GoodsDTO dto:dtos) {
            list.add(toPO(dto));
        }
        return list;
    }


}
